
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>2.Bash的模式扩展 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" >
            
                <span>
            
                    
                    入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../">
            
                <a href="../">
            
                    
                    0.简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="1-basice.html">
            
                <a href="1-basice.html">
            
                    
                    1.基本语法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    基础
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.2.1" data-path="2-globbing.html">
            
                <a href="2-globbing.html">
            
                    
                    2.Bash的模式扩展
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    其他
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="support.html">
            
                <a href="support.html">
            
                    
                    赞助/支持
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >2.Bash的模式扩展</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="bash-&#x7684;&#x6A21;&#x5F0F;&#x6269;&#x5C55;">Bash &#x7684;&#x6A21;&#x5F0F;&#x6269;&#x5C55;</h1>
<h2 id="1&#x3001;-&#x7B80;&#x4ECB;">1&#x3001; &#x7B80;&#x4ECB;</h2>
<p>Shell &#x6536;&#x5230;&#x7528;&#x6237;&#x8F93;&#x5165;&#x7684;&#x547D;&#x4EE4;&#x540E;&#xFF0C;&#x4F1A;&#x6839;&#x636E;&#x7A7A;&#x683C;&#x5C06;&#x7528;&#x6237;&#x7684;&#x8F93;&#x5165;&#xFF0C;&#x62C6;&#x5206;&#x6210;&#x4E00;&#x4E2A;&#x4E2A;<strong>&#x8BCD;&#x5143;</strong>&#xFF08;token&#xFF09;&#x3002;&#x7136;&#x540E;&#xFF0C;Shell &#x4F1A;&#x6269;&#x5C55;&#x8BCD;&#x5143;&#x91CC;&#x9762;&#x7684;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#xFF0C;&#x6269;&#x5C55;&#x5B8C;&#x6210;&#x540E;&#x624D;&#x4F1A;&#x8C03;&#x7528;&#x76F8;&#x5E94;&#x7684;&#x547D;&#x4EE4;&#x3002;  </p>
<p>&#x8FD9;&#x79CD;&#x7279;&#x6B8A;&#x5B57;&#x7B26;&#x7684;&#x6269;&#x5C55;&#xFF0C;&#x6210;&#x4E3A;<strong>&#x6A21;&#x5F0F;&#x6269;&#x5C55;</strong>&#xFF08;globbing&#xFF09;&#x3002;<br>&#x5176;&#x4E2D;&#x6709;&#x4E9B;&#x7528;&#x5230;&#x901A;&#x914D;&#x7B26;&#xFF0C;&#x53C8;&#x79F0;&#x4E3A;&#x901A;&#x914D;&#x7B26;&#x6269;&#x5C55;&#xFF08;wildcard expansion&#xFF09;&#x3002;  </p>
<p>Bash &#x4EE5;&#x4F9B;&#x63D0;&#x4F9B;&#x516B;&#x79CD;&#x6269;&#x5C55;&#xFF1A;  </p>
<ul>
<li>&#x6CE2;&#x6D6A;&#x7EBF;&#x6269;&#x5C55;  </li>
<li><code>?</code> &#x5B57;&#x7B26;&#x6269;&#x5C55;  </li>
<li><code>*</code> &#x5B57;&#x7B26;&#x6269;&#x5C55;  </li>
<li>&#x65B9;&#x62EC;&#x53F7;&#x6269;&#x5C55;  </li>
<li>&#x5927;&#x62EC;&#x53F7;&#x6269;&#x5C55;  </li>
<li>&#x53D8;&#x91CF;&#x6269;&#x5C55;  </li>
<li>&#x5B50;&#x547D;&#x4EE4;&#x6269;&#x5C55;  </li>
<li>&#x7B97;&#x6570;&#x6269;&#x5C55;  </li>
</ul>
<p><strong>Bash &#x662F;&#x5148;&#x8FDB;&#x884C;&#x6269;&#x5C55;&#xFF0C;&#x5728;&#x6267;&#x884C;&#x547D;&#x4EE4;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x6269;&#x5C55;&#x7684;&#x7ED3;&#x679C;&#x662F;&#x7531; Bash &#x8D1F;&#x8D23;&#x7684;&#xFF0C;&#x4E0E;&#x6240;&#x8981;&#x6267;&#x884C;&#x7684;&#x547D;&#x4EE4;&#x65E0;&#x5173;&#x3002;&#x547D;&#x4EE4;&#x672C;&#x8EAB;&#x5E76;&#x4E0D;&#x5B58;&#x5728;&#x53C2;&#x6570;&#x6269;&#x5C55;&#xFF0C;&#x6536;&#x5230;&#x4EC0;&#x4E48;&#x53C2;&#x6570;&#x5C31;&#x662F;&#x539F;&#x6837;&#x6267;&#x884C;&#x3002;&#x8FD9;&#x70B9;&#x52A1;&#x5FC5;&#x7262;&#x8BB0;&#x3002;</strong>  </p>
<hr>
<p><code>globbing</code> &#x8FD9;&#x4E2A;&#x8BCD;&#xFF0C;&#x6765;&#x81EA;&#x4E8E;&#x65E9;&#x671F;&#x7684; Unix &#x7CFB;&#x7EDF;&#x7531;&#x4E00;&#x4E2A; <code>/etc/glob</code> &#x6587;&#x4EF6;&#xFF0C;&#x4FDD;&#x5B58;&#x6269;&#x5C55;&#x7684;&#x6A21;&#x677F;&#x3002;&#x540E;&#x6765; Bash &#x5185;&#x7F6E;&#x4E86;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x4E2A;&#x540D;&#x5B57;&#x5C31;&#x535A;&#x963F;&#x7559;&#x4E0B;&#x6765;&#x4E86;&#x3002;  </p>
<p><strong>&#x6A21;&#x5F0F;&#x6269;&#x5C55;&#x4E0E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x5173;&#x7CFB;</strong>&#x662F;&#xFF0C;&#x6A21;&#x5F0F;&#x6269;&#x5C55;&#x65E9;&#x4E8E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x51FA;&#x73B0;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x4F5C;&#x662F;&#x539F;&#x59CB;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x3002;&#x5B83;&#x7684;&#x529F;&#x80FD;&#x6CA1;&#x6709;&#x6B63;&#x5219;&#x90A3;&#x4E48;&#x5F3A;&#x5927;&#x3001;&#x7075;&#x6D3B;&#xFF0C;&#x4F46;&#x662F;&#x4F18;&#x70B9;&#x662F;&#x7B80;&#x5355;&#x548C;&#x65B9;&#x4FBF;&#x3002;  </p>
<ul>
<li>Bash &#x5141;&#x8BB8;&#x7528;&#x6237;<strong>&#x5173;&#x95ED;&#x6269;&#x5C55;</strong>&#xFF1A;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">set</span> -o <span class="hljs-built_in">noglob</span>

<span class="hljs-comment"># &#x6216;&#x8005;</span>
$ <span class="hljs-built_in">set</span> <span class="hljs-_">-f</span>
</code></pre>
<ul>
<li>&#x4E0B;&#x9762;&#x547D;&#x4EE4;&#x53EF;&#x4EE5;&#x91CD;&#x65B0;<strong>&#x6253;&#x5F00;&#x6269;&#x5C55;</strong>&#xFF1A;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">set</span> +o <span class="hljs-built_in">noglob</span>

<span class="hljs-comment"># &#x6216;&#x8005;</span>
$ <span class="hljs-built_in">set</span> +f
</code></pre>
<hr>
<h2 id="2&#x3001;-&#x6CE2;&#x6D6A;&#x7EBF;&#x6269;&#x5C55;">2&#x3001; &#x6CE2;&#x6D6A;&#x7EBF;&#x6269;&#x5C55;</h2>
<ul>
<li>&#x6CE2;&#x6D6A;&#x7EBF; <code>~</code> &#x4F1A;&#x81EA;&#x52A8;&#x6269;&#x5C55;&#x6210;<strong>&#x5F53;&#x524D;&#x7528;&#x6237;&#x7684;&#x4E3B;&#x76EE;&#x5F55;</strong>&#x3002;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">echo</span> ~
/home/me
</code></pre>
<ul>
<li><code>~/dir</code> &#x8868;&#x793A;&#x6269;&#x5C55;&#x6210;<strong>&#x4E3B;&#x76EE;&#x5F55;&#x7684;&#x67D0;&#x4E2A;&#x5B50;&#x76EE;&#x5F55;</strong>&#xFF0C;<code>dir</code> &#x662F;&#x4E3B;&#x76EE;&#x5F55;&#x91CC;&#x9762;&#x7684;&#x4E00;&#x4E2A;&#x5B50;&#x76EE;&#x5F55;&#x540D;&#x3002;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x8FDB;&#x5165; /home/me/foo &#x76EE;&#x5F55;</span>
$ <span class="hljs-built_in">cd</span> ~/foo
</code></pre>
<ul>
<li><code>~user</code> &#x8868;&#x793A;&#x6269;&#x5C55;&#x6210;<strong>&#x7528;&#x6237; <code>user</code> &#x7684;&#x4E3B;&#x76EE;&#x5F55;</strong>&#x3002;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">echo</span> ~foo
/home/foo

$ <span class="hljs-built_in">echo</span> ~root
/root
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;Bash &#x4F1A;&#x6839;&#x636E;&#x6CE2;&#x6D6A;&#x53F7;&#x540E;&#x9762;&#x7684;&#x7528;&#x6237;&#x540D;&#xFF0C;&#x8FD4;&#x56DE;&#x8BE5;&#x7528;&#x6237;&#x7684;&#x4E3B;&#x76EE;&#x5F55;&#x3002;  </p>
<ul>
<li>&#x5982;&#x679C; <code>~user</code> &#x7684; <code>user</code> &#x662F;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x7528;&#x6237;&#x540D;&#xFF0C;&#x5219;&#x6CE2;&#x6D6A;&#x53F7;&#x6269;&#x5C55;&#x4E0D;&#x8D77;&#x4F5C;&#x7528;&#x3002;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">echo</span> ~nonExistedUser
~nonExistedUser
</code></pre>
<ul>
<li><code>~+</code> &#x4F1A;&#x6269;&#x5C55;&#x6210;&#x5F53;&#x524D;&#x6240;&#x5728;&#x7684;&#x76EE;&#x5F55;&#xFF0C;&#x7B49;&#x540C;&#x4E8E; <code>pwd</code> &#x547D;&#x4EE4;&#x3002;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">cd</span> ~/foo
$ eho ~+
/home/me/foo
</code></pre>
<hr>
<h2 id="3&#x3001;--&#x5B57;&#x7B26;&#x6269;&#x5C55;">3&#x3001; <code>?</code> &#x5B57;&#x7B26;&#x6269;&#x5C55;</h2>
<ul>
<li><code>?</code> &#x5B57;&#x7B26;&#x4EE3;&#x8868;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x91CC;&#x9762;&#x7684;&#x4EBA;&#x4EE5;<strong>&#x5355;&#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x4E0D;&#x5305;&#x62EC;&#x7A7A;&#x683C;&#x7B26;</strong>&#x3002;<br>&#x6BD4;&#x5982;&#xFF0C;<code>Data???</code> &#x5339;&#x914D;&#x6240;&#x6709; <code>Data</code> &#x540E;&#x9762;&#x8DDF;&#x7740;&#x4E09;&#x4E2A;&#x5B57;&#x7B26;&#x7684;&#x6587;&#x4EF6;&#x540D;&#x3002;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5B58;&#x5728;&#x6587;&#x4EF6; a.txt &#x548C; b.txt</span>
$ ls ?.txt
a.txt b.txt
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;<code>?</code> &#x8868;&#x793A;&#x5355;&#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x6240;&#x4EE5;&#x4F1A;&#x540C;&#x65F6;&#x5339;&#x914D; <code>a.txt</code> &#x548C; <code>b.txt</code> &#x3002;  </p>
<hr>
<ul>
<li>&#x5982;&#x679C;<strong>&#x5339;&#x914D;&#x591A;&#x4E2A;&#x5B57;&#x7B26;</strong>&#xFF0C;&#x5C31;&#x9700;&#x8981;&#x591A;&#x4E2A; <code>?</code> &#x8FDE;&#x7528;&#x3002;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5B58;&#x5728;&#x6587;&#x4EF6; a.txt &#x3001;b.txt &#x548C; ab.txt</span>
$ ls ??.txt
ab.txt
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C; <code>??</code> &#x5339;&#x914D;&#x4E86;&#x4E24;&#x4E2A;&#x5B57;&#x7B26;&#x3002;  </p>
<hr>
<ul>
<li><code>?</code> &#x5B57;&#x7B26;&#x6269;&#x5C55;&#x5C5E;&#x4E8E;&#x6587;&#x4EF6;&#x540D;&#x6269;&#x5C55;&#xFF0C;&#x53EA;&#x6709;&#x6587;&#x4EF6;&#x786E;&#x5B9E;&#x5B58;&#x5728;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#xFF0C;&#x624D;&#x4F1A;&#x53D1;&#x751F;&#x6269;&#x5C55;&#x3002;<br>&#x5982;&#x679C;&#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x6269;&#x5C55;&#x5C31;&#x4E0D;&#x4F1A;&#x53D1;&#x751F;&#x3002;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5F53;&#x524D;&#x76EE;&#x5F55;&#x7531; a.txt &#x6587;&#x4EF6;</span>
$ <span class="hljs-built_in">echo</span> ?.txt
a.txt

<span class="hljs-comment"># &#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E3A;&#x7A7A;</span>
$ <span class="hljs-built_in">echo</span> ?.txt
?.txt
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;&#x5982;&#x679C; <code>?.txt</code> &#x53EF;&#x4EE5;&#x6269;&#x5C55;&#x6210;&#x6587;&#x4EF6;&#x540D;&#xFF0C; <code>echo</code> &#x547D;&#x4EE4;&#x4F1A;&#x8F93;&#x51FA;&#x6269;&#x5C55;&#x540E;&#x7684;&#x7ED3;&#x679C;&#xFF1B;&#x5982;&#x679C;&#x4E0D;&#x80FD;&#x6269;&#x5C55;&#x6210;&#x6587;&#x4EF6;&#xFF0C;<code>echo</code> &#x5C31;&#x4F1A;&#x539F;&#x6837;&#x8F93;&#x51FA; <code>?.txt</code> &#x3002;  </p>
<hr>
<h2 id="4&#x3001;--&#x5B57;&#x7B26;&#x6269;&#x5C55;">4&#x3001; <code>*</code> &#x5B57;&#x7B26;&#x6269;&#x5C55;</h2>
<ul>
<li><code>*</code> &#x5B57;&#x7B26;&#x4EE3;&#x8868;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x91CC;&#x9762;&#x7684;<strong>&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x4EFB;&#x610F;&#x5B57;&#x7B26;</strong>&#xFF0C;&#x5305;&#x62EC;&#x96F6;&#x4E2A;&#x5B57;&#x7B26;&#x3002;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5B58;&#x5728;&#x6587;&#x4EF6; a.txt &#x3001;b.txt &#x548C; ab.txt</span>
$ ls *.txt
a.txt b.txt ab.txt
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;<code>*.txt</code> &#x4EE3;&#x8868;&#x540E;&#x7F00;&#x540D;&#x4E3A; <code>.txt</code> &#x7684;&#x6240;&#x6709;&#x6587;&#x4EF6;&#x3002;  </p>
<hr>
<ul>
<li>&#x5982;&#x679C;&#x60F3;&#x8981;&#x8F93;&#x51FA;&#x5F53;&#x524D;&#x76EE;&#x5F55;<strong>&#x6240;&#x6709;&#x6587;&#x4EF6;</strong>&#xFF0C;&#x76F4;&#x63A5;&#x4F7F;&#x7528; <code>*</code> &#x5373;&#x53EF;&#x3002;  </li>
</ul>
<pre><code class="lang-bash">$ ls *
</code></pre>
<ul>
<li><code>*</code> &#x53EF;&#x4EE5;&#x5339;&#x914D;<strong>&#x7A7A;&#x5B57;&#x7B26;</strong>&#xFF0C;&#x5982;&#x4E0B;&#x4F8B;&#xFF1A;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5B58;&#x5728;&#x6587;&#x4EF6; a.txt &#x3001;b.txt &#x548C; ab.txt</span>
$ ls a*.txt
a.txt ab.txt

$ ls *b*
b.txt ab.txt
</code></pre>
<hr>
<ul>
<li>&#x6CE8;&#x610F; <strong><code>*</code> &#x4E0D;&#x4F1A;&#x5339;&#x914D;&#x9690;&#x85CF;&#x6587;&#x4EF6;</strong>&#xFF08;&#x4EE5; <code>.</code> &#x5F00;&#x5934;&#x7684;&#x6587;&#x4EF6;&#xFF09;&#xFF0C;&#x5373; <code>ls *</code> &#x4E0D;&#x4F1A;&#x8F93;&#x51FA;&#x9690;&#x85CF;&#x6587;&#x4EF6;&#x3002;  </li>
</ul>
<p>&#x5982;&#x679C;&#x8981;&#x5339;&#x914D;&#x9690;&#x85CF;&#x6587;&#x4EF6;&#xFF0C;&#x9700;&#x8981;&#x5199;&#x6210; <code>.*</code> &#x3002;  </p>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x663E;&#x793A;&#x6240;&#x6709;&#x9690;&#x85CF;&#x6587;&#x4EF6;</span>
$ <span class="hljs-built_in">echo</span> .*
</code></pre>
<ul>
<li>&#x5982;&#x679C;&#x8981;&#x5339;&#x914D;&#x9690;&#x85CF;&#x6587;&#x4EF6;&#xFF0C;&#x540C;&#x65F6;&#x8981;&#x914D;&#x51FA; <code>.</code> &#x548C; <code>..</code> &#x7740;&#x4E24;&#x4E2A;&#x7279;&#x6B8A;&#x9690;&#x85CF;&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x4E8E;&#x65B9;&#x62EC;&#x53F7;&#x6269;&#x5C55;&#x7ED3;&#x5408;&#x4F7F;&#x7528;&#xFF0C;&#x5199;&#x6210; <code>.[!.]*</code> &#x3002;  </li>
</ul>
<pre><code class="lang-bash">$ <span class="hljs-built_in">echo</span> .[!.]*
</code></pre>
<p><strong>&#x6CE8;&#x610F;</strong> <code>*</code> &#x5B57;&#x7B26;&#x6269;&#x5C55;&#x5C5E;&#x4E8E;&#x6587;&#x4EF6;&#x540D;&#x6269;&#x5C55;&#xFF0C;&#x53EA;&#x6709;&#x6587;&#x4EF6;&#x786E;&#x5B9E;&#x5B58;&#x5728;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#x624D;&#x4F1A;&#x6269;&#x5C55;&#x3002;&#x5982;&#x679C;&#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x5C31;&#x4F1A;&#x539F;&#x6837;&#x8F93;&#x51FA;&#x3002;  </p>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0D;&#x5B58;&#x5728; c &#x5F00;&#x5934;&#x7684;&#x6587;&#x4EF6;</span>
$ <span class="hljs-built_in">echo</span> c*.txt
c*.txt
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x91CC;&#x9762;&#x6CA1;&#x6709; <code>c</code> &#x5F00;&#x5934;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x5BFC;&#x81F4; <code>c*.txt</code> &#x4F1A;&#x539F;&#x6837;&#x8F93;&#x51FA;&#x3002;  </p>
<hr>
<ul>
<li><code>*</code> &#x53EA;&#x5339;&#x914D;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#xFF0C;&#x4E0D;&#x4F1A;&#x5339;&#x914D;&#x5B50;&#x76EE;&#x5F55;&#x3002;  </li>
</ul>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x5B50;&#x76EE;&#x5F55;&#x7531;&#x4E00;&#x4E2A; a.txt</span>
<span class="hljs-comment"># &#x65E0;&#x6548;&#x7684;&#x5199;&#x6CD5;</span>
$ ls *.txt

<span class="hljs-comment"># &#x6709;&#x6548;&#x7684;&#x5199;&#x6CD5;</span>
$ ls */*.txt
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;&#x6587;&#x672C;&#x6587;&#x4EF6;&#x5728;&#x5B50;&#x76EE;&#x5F55;&#xFF0C; <code>*.txt</code> &#x4E0D;&#x4F1A;&#x4EA7;&#x751F;&#x5339;&#x914D;&#xFF0C;&#x5FC5;&#x987B;&#x5199;&#x51FA; <code>*/*.txt</code> &#x3002;<br>&#x6709;&#x51E0;&#x5C42;&#x5B50;&#x76EE;&#x5F55;&#xFF0C;&#x5C31;&#x5FC5;&#x987B;&#x5199;&#x51E0;&#x5C42;&#x661F;&#x53F7;&#x3002;  </p>
<p>Bash 4.0 &#x5F15;&#x5165;&#x4E86;&#x4E00;&#x4E2A;&#x53C2;&#x6570; <code>globstar</code> &#xFF0C;&#x5F53;&#x8BE5;&#x53C2;&#x6570;&#x6253;&#x5F00;&#x65F6;&#xFF0C;&#x5141;&#x8BB8; <code>**</code> &#x5339;&#x914D;&#x96F6;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x5B50;&#x76EE;&#x5F55;&#x3002;<br>&#x56E0;&#x6B64;&#xFF0C; <code>**/*.txt</code> &#x53EF;&#x4EE5;&#x5339;&#x914D;&#x9876;&#x5C42;&#x7684;&#x6587;&#x672C;&#x6587;&#x4EF6;&#x548C;&#x4EFB;&#x610F;&#x6DF1;&#x5EA6;&#x5B50;&#x76EE;&#x5F55;&#x7684;&#x6587;&#x672C;&#x6587;&#x4EF6;&#x3002;  </p>
<hr>
<h2 id="5&#x3001;-&#x65B9;&#x62EC;&#x53F7;&#x6269;&#x5C55;">5&#x3001; &#x65B9;&#x62EC;&#x53F7;&#x6269;&#x5C55;</h2>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"2.Bash的模式扩展","level":"1.2.1","depth":2,"next":{"title":"其他","level":"1.3","depth":1,"ref":"","articles":[{"title":"赞助/支持","level":"1.3.1","depth":2,"path":"docs/support.md","ref":"./docs/support.md","articles":[]}]},"previous":{"title":"基础","level":"1.2","depth":1,"ref":"","articles":[{"title":"2.Bash的模式扩展","level":"1.2.1","depth":2,"path":"docs/2-globbing.md","ref":"./docs/2-globbing.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docs/2-globbing.md","mtime":"2020-07-12T10:10:22.128Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-12T10:16:31.568Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

